package cn.czh0123.enums;

public enum WallpaperOperateType {
    /**
     * 浏览操作
     */
    VIEW(0, "浏览"),

    /**
     * 评论操作
     */
    COMMENT(1, "评论"),

    /**
     * 收藏操作
     */
    COLLECT(2, "收藏"),

    /**
     * 点赞操作
     */
    LIKE(3, "点赞"),

    /**
     * 下载数
     */
    DOWNLOAD(4, "下载");

    private final int code;
    private final String description;

    WallpaperOperateType(int code, String description) {
        this.code = code;
        this.description = description;
    }

    public int getCode() {
        return code;
    }

    public String getDescription() {
        return description;
    }

    /**
     * 根据操作码获取对应的枚举类型
     * @param code 操作码
     * @return 枚举类型
     */
    public static WallpaperOperateType fromCode(int code) {
        for (WallpaperOperateType type : values()) {
            if (type.getCode() == code) {
                return type;
            }
        }
        throw new IllegalArgumentException("Invalid action code: " + code);
    }
}
